package br.com.spread.svnutils;

import java.util.ResourceBundle;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Config {
	private static ResourceBundle config = ResourceBundle.getBundle("synch");
	
	public static final String getString(String key){
		
		String value = config.getString(key);
		
		Pattern p = Pattern.compile("\\$\\{[a-zA-Z0-9\\.]*\\}");
		Matcher m = p.matcher(value);
		while (m.find()){
			String var = value.substring(m.start(), m.end());
			value = value.substring(0, m.start()) + 
					(config.getString(var.substring(2, var.length() - 1))) + value.substring(m.end()); 
			m = p.matcher(value);
		}
		
		return value;
	}
	
	public static void main2(String[] args) {
		String var = "$base.dir/etc/iot/floder".replaceAll("\\$base.dir", "bolha");
		System.out.println(var);
	}
}
